import requests

def getHTMLText(url):
    try:
        r=requests.get(url)
        r.raise_for_status()
        print(r.status_code)
        r.encoding=r.apparent_encoding
        dome=r.text
        output(dome)
        print("抓取成功")
    except:
        print("抓取失败")
def output(data=''):
    file = open("output.html","w",encoding="utf-8")
    file.write(data)
    file.close()
    
def main():
    url = "http://www.xbmu.edu.cn/frontIndex.action?siteId=1"
    getHTMLText(url)


main()
